package com.example.myfirstapp;

import org.openintents.intents.WikitudeARIntent;
import org.openintents.intents.WikitudePOI;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import org.openintents.*;

public class MiRealidadAumentada extends Activity {

	
	private static final WikitudeARIntent AbstractWikitudeARIntent = null;
	private Resources getResources;

	@Override
	public void onCreate(Bundle savedInstanceState){
		
		super.onCreate(savedInstanceState);
		
		Button b=(Button)findViewById(R.id.button1);
		
		b.setOnClickListener(new OnClickListener(){
			
			@Override
			public void onClick(View v){
				launchARView();
			}
		});
		
		
		/*public void launchARView(){
			//WikitudeARIntent (Application application, String applicationKey, 
			//String developerName, boolean debugMode)
			WikitudeARIntent intent =new WikitudeARIntent(this.getApplication(),null,null,true);
			addPois(intent);
			
			try{
				intent.startIntent(this);
			}catch(ActivityNotFoundException e){
				AbstractWikitudeARIntent.handleWikitudeNotFound(this);
			}
			
		}
		
		private void addPois(WikitudeARIntent intent1){
			
		}*/
		
	}

	protected void launchARView() {
		// TODO Auto-generated method stub
		//WikitudeARIntent (Application application, String applicationKey, 
		//String developerName, boolean debugMode)
		WikitudeARIntent intent =new WikitudeARIntent(this.getApplication(),null,null,true);
		addPois(intent);
		
		try{
			intent.startIntent(this);
		}catch(ActivityNotFoundException e){
			AbstractWikitudeARIntent.handleWikitudeNotFound(this);
		}
		
	}

	private void addPois(WikitudeARIntent intent) {
		// TODO Auto-generated method stub
		
		Resources res = getResources();
		 
		WikitudePOI poi = new WikitudePOI(40.441346, -3.785702,636, "INSDOUT", "HI I AM AN IDEA WANNA PLAY WITH ME?");
		 
		poi.setLink("http://www.insdout.com.com/");
		 
		//Resources getResources;
		poi.setIconresource(getResources.getResourceName(R.drawable.ic_launcher));
		 
		intent.addPOI(poi);

		
		
		
	}

	
}
